// 顺序请求,全部完成后返回最后请求结果,中间有失败则停止继续请求,直接返回失败的结果
// 127.0.0.1:3000/proxy/queue/s?query=[{"path":"serveruser\/user\/User\/login","param":{"phone":"13181262939","login_password":"12345678","token":"b49baca86cf59b174feae087a63d8656"}}]
// 127.0.0.1:3000/proxy/queue/s?query=[{"path":"serveruser\/user\/User\/list","param":{"page":"1","list_rows":"15"}}]
// 127.0.0.1:3000/proxy/queue/s?query=[{"path":"serveruser\/user\/User\/list","param":{"page":"1","list_rows":"15"}},{"path":"serveruser\/user\/User\/info","param":{"id":"1"}}]&success=1,0

// post方式  127.0.0.1:3000/proxy/queue
// {"query":[{"path":"serveruser/user/User/list","param":{"page":"1","list_rows":"15"}},{"path":"serveruser/user/User/info","param":{"id":"1"}}],"success":"1,0"}

const express = require('express')
const router = express.Router()

// 获取get参数
const getParam = require('../dispatch/getParam')
// 获取post参数
const postParam = require('../dispatch/postParam')

// 顺序请求队列的方法
const queueQuery = require('../dispatch/queueQuery')

router.get('/', function(req, res, next) {
    let {query, successArr} = getParam(req, res, next)
//res.json({type:typeof(query), query, successArr})
    queueQuery(req, res, next, query, successArr)
})

router.post('/', function(req, res, next) {
    let {query, successArr} = postParam(req, res, next)
    queueQuery(req, res, next, query, successArr)
})

module.exports = router
